package main

import (
	"log"
	"os"
	"os/signal"
	"syscall"

	"github.com/panjf2000/gnet/v2"
	server "github.com/skyjiang/kvrocks-go"
)

func main() {
	rs, err := server.NewRedisServer("tcp://172.30.3.11:30300", "build/data")
	if err != nil {
		log.Printf("create server fail:%s\n", err.Error())
		return
	}

	go func() {
		log.Fatal(gnet.Run(rs, rs.Addr, gnet.WithMulticore(true)))
	}()

	sigCh := make(chan os.Signal, 1)
	signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
	sig := <-sigCh
	log.Printf("Got signal [%s] to exit.", sig)

	rs.Shutdown()
}
